package j01zhengze;

import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class J4 {
    public static void main(String[] args) {
        System.out.println("abc".matches("ab\\w"));//true
        System.out.println("ab$".matches("ab\\w"));//false
        System.out.println("ab ".matches("ab\\s"));//true
        System.out.println("ab\t".matches("ab\\s"));//true
    }
}
class J5{
    public static void main(String[] args) {
        Pattern p = Pattern.compile("a\\dc");//正则规则
        Matcher m = p.matcher("abc");//字符串
        boolean flag = m.matches();
        System.out.println("flag = " + flag);

        System.out.println("====");
        boolean flag2 = Pattern.matches("\\Sabc"," abc");//false
    }
}
/*
判断录入的手机号是否为13或者18开头
 */
class J6{
    public static void main(String[] args) {
        System.out.println("265362536".matches("1[38]\\d{9}"));//false
        System.out.println("1366666".matches("1[38]\\d{9}"));//false
        System.out.println("13000000000".matches("1[38]\\d{9}"));//true

        System.out.println("====");
        String s = "5ba77cd99sk88";
        String[] arr = s.split("[a-z]{2}");
        System.out.println(Arrays.toString(arr));

    }
}

class J7tiqu{
    public static void main(String[] args) {
        String s = "as44df6666gjklej77kx888cvbnm";
        Pattern p = Pattern.compile("\\d+");
        Matcher m = p.matcher(s);

        while (m.find()){
            System.out.println(m.group());
        }

//        System.out.println(m.find());//
//        System.out.println(m.group());//目标字符串
//        System.out.println(m.find());//
//        System.out.println(m.group());//目标字符串
//        System.out.println(m.find());//
//        System.out.println(m.group());//目标字符串
//        System.out.println(m.find());//
//        System.out.println(m.group());//目标字符串
//        System.out.println(m.find());//
//        System.out.println(m.group());//目标字符串
//        System.out.println(m.find());//
//        System.out.println(m.group());//目标字符串
//        System.out.println(m.find());//
//        System.out.println(m.group());//目标字符串
//        System.out.println(m.find());//
//        System.out.println(m.group());//目标字符串
//        System.out.println(m.find());//
//        System.out.println(m.group());//目标字符串
//        System.out.println(m.find());//
//        System.out.println(m.group());//目标字符串
    }
}

class J8{
    public static void main(String[] args) {
        System.out.println("你好".matches("[\\u4e00-\\u9fa5]{0,}"));
        System.out.println("你a好".matches("[\\u4e00-\\u9fa5]{0,}"));//false
    }
}